package com.android.lovely.room.search

import androidx.room.Dao
import androidx.room.Insert
import androidx.room.OnConflictStrategy
import androidx.room.Query
import kotlinx.coroutines.flow.Flow

/**
 *
 * @author why
 * @date 2025/3/13 14:34
 */
@Dao
interface SearchDao {
    @Query("select * from search where owner_id=:userId order by update_time DESC")
    fun queryAll(userId: Int): Flow<List<SearchEntity>>

    @Insert(onConflict = OnConflictStrategy.REPLACE)
    suspend fun insert(profile: SearchEntity)

    @Query("delete from search where search_key = :key")
    suspend fun delete(key: String)

    @Query("delete from search where owner_id = :userId")
    suspend fun deleteAll(userId: Int)
}